import os
from base.basicFunction import *
from selenium.webdriver.common.by import By


def order_tracking():
    logger.info("-" * 30 + "订单查询" + "-" * 30)
    switch_to_frame((By.ID, 'myFrame1'))
    Element((By.XPATH, '//*[@id="FinishedQueryPart"]/ul/li[14]/div/button')).click()  # 点击查询
    sleep(1)
    Element((By.ID, 'reportALL_button')).click()  # 点击导出excel
    Element((By.XPATH, '//*[@id="reportALL_float"]/div[2]/div/span/button/span[text()="导出"]')).click()  # 点击导出
    Element((By.XPATH, '//*[@id="reportALL_float"]/div[2]/div/div[2]/a')).click()  # 下载导出文件
    # 删除本地下载文件
    sleep(5)
    # path = 'C:\\Users\\admin\\Downloads\\'
    path = 'E:\\下载\\'
    del_files = [file for file in os.listdir(path) if '订单查询' in file]
    for del_file in del_files: os.remove(path + del_file)
    logger.info("-" * 28 + "订单查询完成" + "-" * 28)
